#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import json
import logging

from restrpc.rpc_worker import RPCWorker

amqp_url = 'amqp://admin:123456@172.16.1.156'


logging.basicConfig(level=logging.DEBUG)


class OCRRPCWorker(RPCWorker):
    def __init__(self):
        super(OCRRPCWorker, self).__init__('ocr', amqp_url)

    def do_task(self, task):
        task_result = {'status': 'done', 'source': task}

        return json.dumps(task_result)


def rpc_worker():
    from multiprocessing import Process

    worker = OCRRPCWorker()
    worker.start()

    # proc = Process(target=worker.start)
    # proc.daemon = True
    # proc.start()

    print('===> OCRRPCWorker start...', )



if __name__ == '__main__':
    rpc_worker()
